//
//  LKDownLoadModel.h
//  zlsn
//
//  Created by wangzheng on 2018/4/4.
//  Copyright © 2018年 Luculent. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, LKDownLoadState) {
    LKDownLoadStateWaiting = 0,
    LKDownLoadStateRunning,
    LKDownLoadStateSuspended,
    LKDownLoadStateCanceled,
    LKDownLoadStateCompleted,
    LKDownLoadStateFailed
};

@interface LKDownLoadModel : NSObject

@property (nonatomic, strong) NSOutputStream *outputStream; // 输出流写入数据 下载文件时，一边下载一边写入到磁盘，减小内存使用
@property (nonatomic, strong) NSURL *URL;
@property (nonatomic, copy) NSString *fileName;
@property (nonatomic, assign) NSInteger totalLength;
@property (nonatomic, strong) NSURLSessionDataTask *dataTask;
@property (nonatomic, copy) void (^progress)(NSInteger receivedSize, NSInteger expectedSize, CGFloat progress);
@property (nonatomic, copy) void (^completion)(BOOL isSuccess, NSString *filePath, NSError *error);
@property (nonatomic, copy) void (^state)(LKDownLoadState state);

- (void)closeOutputStream;

- (void)openOutputStream;

/*
 https://www.jianshu.com/p/b63217ff7287
 */

@end
